package com.yuan.statemachine.core;

import java.util.Objects;

/**
 * @author wjwei
 * 状态机实现实体类，能够标识定位唯一的抽象状态机实现
 */
public class StateEntry<F extends Enum<F>, S extends Enum<S>, E extends Enum<E>> {

    private AbstractStateMachine<F, S, E> state;
    private Enum<S> statusEnum;

    public StateEntry() {
    }

    public StateEntry(AbstractStateMachine<F, S, E> state, Enum<S> statusEnum) {
        this.state = state;
        this.statusEnum = statusEnum;
    }

    public AbstractStateMachine<F, S, E> getState() {
        return state;
    }

    public void setState(AbstractStateMachine<F, S, E> state) {
        this.state = state;
    }

    public Enum<S> getStatusEnum() {
        return statusEnum;
    }

    public void setStatusEnum(Enum<S> statusEnum) {
        this.statusEnum = statusEnum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        StateEntry<?, ?, ?> entry = (StateEntry<?, ?, ?>) o;
        return state.equals(entry.state) &&
                statusEnum.equals(entry.statusEnum);
    }

    @Override
    public int hashCode() {
        return Objects.hash(state, statusEnum);
    }
}
